<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>登录页面</title>
		<style>
			body{
				width: 100%;
				height: 100%;
				background: url(body.jpg);
			    background-size: cover;	
			}
			*{margin: 0;padding: 0;}
			.warp{
				width: 300px;
				height: 300px;
				
				margin: 50px auto;
		
			}
			h6{
		/* 		font-weight: normal; */
				/* padding-left: 10px; */
				padding-top: 10px;
				font-family: "楷体";
			}
			input{
				margin-left: 10px;
				margin-top: 20px;
			}
			button{
				display:block;
				margin-top: 20px;
				margin-left: 10px;
				
			}
			p{
				margin-right: 10px;
			}
			
		</style>
	</head>
	<body>
		 <div class="warp">
			 <h2>页面登陆</h2>
			<h3>用户名:<input type="text" class="user"></h3>
			<h3>密码:<input type="text" class="password"></h3>
			<p><input type="checkbox" class="check">30天免登录</p>
			<button class="login">登录</button>
		 </div>
		 <script src="jquery.min.js"></script>
		 <script src="comment.js"></script>
		 <script>
			 let user = $(".user")
			 let password = $(".password")
			 $(".login").click(function(){ 
				if(user.val() && password.val()){
				 $.ajax({
					url:`${address}/login`,
					data:{
						user:user.val(),
						password:password.val()
					},
					success(data){
						if(data === "2"){
							alert("用户名或者密码没填写正确")
						}
						else{
							
							let stringdata = JSON.stringify(data)
							sessionStorage.setItem("storagesource",stringdata) 	
						    location.href = `${address}/student.html`
							if($(".check")[0].checked){
								let date = new Date()
								date.setDate(date.getDate() + 30)
								document.cookie = `cookiesource=${stringdata};expires=${date}`
								location.href = `${address}/student.html`
							}
						}
					}
				 })
				 }
			 })
		 </script>
	</body>
</html>
